package cn.mrcode.fd.plugin.security;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.Set;

/**
 * @author zhuqiang
 * @version V1.0
 * @date 2015/11/16 20:04
 */
public class SmartSecurityPlugin implements ServletContainerInitializer {
    @Override
    public void onStartup(Set<Class<?>> set, ServletContext servletContext) throws ServletException {
       /* //这样能获取到
        String pluginSecurity = servletContext.getInitParameter("pluginSecurity");
        new File(this.getClass().getClassLoader().getResource("jdbc.properties").getPath()).exists();
      */
        /*String pluginSecurity = servletContext.getInitParameter("pluginSecurity");
        //设置初始化参数
        servletContext.setInitParameter("shiroConfigLocations","classpath:shiro.ini");//覆盖掉默认的shiro配置文件名称
        servletContext.addListener(EnvironmentLoaderListener.class); //标准的shiro的启动配置项
        FilterRegistration.Dynamic smartSecurityFilter = servletContext.addFilter("SmartSecurityFilter", SmartSecurityFilter.class);
        smartSecurityFilter.addMappingForUrlPatterns(null,false,"*//**//*"); //加载我们自己的filter。并设置拦截路径*/
    }
}
